from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from items.treasure import Treasure
from core.support import set_cutscene

class TreasureRoom(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        # add inventory items
        #self.add_item(Treasure())
        
        # build list of actions
        #self.add_action(Code1)
        #self.add_action(Code2)
        #self.add_action(Code3)
        #self.add_action(Code4)
    
    # return description of room.
    def get_description(self):
        return "You are standing in front of a treasure chest. You need to guess the code to open the chest."
    
    # return image of room
    def get_image(self):
        return 'chest_close.jpg'

class TreasureRoomHandler(BaseHandler):
    
    def get_template(self):
        return 'index.html'
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return TreasureRoom

    def post(self):
        
        code = self.request.get('code')
        if code == "SK666":
            self.redirect('final')
        else:
            set_cutscene("You entered the wrong code! Try again.")    
            BaseHandler.post(self)